package io.renren.modules.myCourse.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.myCourse.dao.ChooseTestDao;
import io.renren.modules.myCourse.entity.ChooseTestEntity;
import io.renren.modules.myCourse.service.ChooseTestService;


@Service("chooseTestService")
public class ChooseTestServiceImpl extends ServiceImpl<ChooseTestDao, ChooseTestEntity> implements ChooseTestService {


    @Autowired
    ChooseTestDao chooseTestDao;

    private boolean isNull(Integer i){
        if(i==null)
            return false;
        else
            return true;
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

//        Integer chapterId = (Integer) params.get("chapterId");
//        boolean ischapterId=isNull(chapterId);
//        Integer sectionId = (Integer) params.get("sectionId");
//        boolean issectionId=isNull(sectionId);
        Page<ChooseTestEntity> page = this.selectPage(
                new Query<ChooseTestEntity>(params).getPage(),
                new EntityWrapper<ChooseTestEntity>()
                .eq("course_body_id",(String) params.get("courseBodyId"))
//                .eq(ischapterId,"chapter_id", chapterId)
//                .eq(issectionId,"section_id", sectionId)
        );

        return new PageUtils(page);
    }

    @Override
    public void delquestonContentImg(Integer id) {
        chooseTestDao.delquestonContentImg(id);
    }

    @Override
    public void delquestonOneImg(int id) {
        chooseTestDao.delquestonOneImg(id);
    }

    @Override
    public void delquestonTwoImg(int id) {
        chooseTestDao.delquestonTwoImg(id);
    }

    @Override
    public void delquestonThreeImg(int id) {
        chooseTestDao.delquestonThreeImg(id);
    }

    @Override
    public void delquestonFourImg(int id) {
        chooseTestDao.delquestonFourImg(id);
    }

    @Override
    public void delquestonAlaisImg(int id) {
        chooseTestDao.delquestonAlaisImg(id);
    }

}
